# SourceSignal测试类
import unittest
import matplotlib.pyplot as plt
import torch
from apps.exp.exp_config import ExpConfig as EG
from apps.exp.source_signal import SourceSignal

class TSourceSignal(unittest.TestCase):
    # python -m unittest -v uts.apps.exp.t_source_signal.TSourceSignal.test_generate_signal
    def test_generate_signal(self):
        s = SourceSignal.generate_signal()
        print(f's: {s.shape};')
        plt.figure(figsize=(12, 10))
        # 发射信号时频分析
        plt.subplot(3,1,1)
        plt.plot(EG.t.numpy()*1e6, torch.real(s).numpy())
        plt.title('Transmit Signal (Real Part)')
        plt.xlabel('Time [μs]')
        plt.grid(True)
        plt.show()